package com.hongsuan.pplive.mobileAPI.utils;

import java.util.Date;

import com.hongsuan.pplive.mobileAPI.vo.GoldContribution;
import com.hongsuan.pplive.mobileAPI.vo.Recording;
import com.hongsuan.pplive.mobileAPI.vo.Room;
import com.hongsuan.pplive.modules.live.entity.LiveGoldContribution;
import com.hongsuan.pplive.modules.live.entity.LiveRecording;
import com.hongsuan.pplive.modules.live.entity.LiveRoom;
import com.hongsuan.pplive.modules.sys.entity.User;

import me.chanjar.weixin.common.util.StringUtils;

public final class Convertor {

	public static com.hongsuan.pplive.mobileAPI.vo.UserVo userConvert2Vo(User user) {
		com.hongsuan.pplive.mobileAPI.vo.UserVo vo = new com.hongsuan.pplive.mobileAPI.vo.UserVo();
		if (user != null) {
			// vo.setEmail(user.getEmail());
			// vo.setAreaId(user.getAreaId());
			// vo.setAccount(user.getAccount());
			// vo.setEmpiricalValue(user.getEmpiricalValue());
			// vo.setGold(user.getGold());
			// vo.setId(user.getId());
			// vo.setLevel(user.getLevel());
			// vo.setLiveLevel(user.getLiveLevel());
			// vo.setLoginDate(user.getLoginDate());
			// vo.setLoginIp(user.getLoginIp());
			// vo.setLoginName(user.getLoginName());
			// vo.setMobile(user.getMobile());
			// vo.setMyConsumption(user.getMyConsumption());
			// vo.setMyIncome(user.getMyIncome());
			vo.setName(user.getName());
			vo.setNickName(user.getNickName());
			vo.setOnlineState(user.getOnlineState());
			// vo.setPassword(user.getPassword());
			// vo.setLocation(user.getLocation());
			// vo.setPhone(user.getPhone());
			vo.setPhoto(user.getPhoto());
			vo.setSex(user.getSex());
			// vo.setSignature(user.getSignature());
			vo.setUserType(user.getUserType());
			// vo.setAuthenStatus(user.getAuthenStatus());
			// vo.setSig(user.getSig());
		}
		return vo;
	}

	public static User voConvert2User(com.hongsuan.pplive.mobileAPI.vo.UserVo vo) {
		User userInfo = new User();
		if (vo != null) {
			// userInfo.setAccount(vo.getAccount());
			// userInfo.setAreaId(vo.getAreaId());
			// userInfo.setEmail(vo.getEmail());
			// userInfo.setEmpiricalValue(vo.getEmpiricalValue());
			// userInfo.setGold(vo.getGold());
			userInfo.setId(vo.getId());
			// userInfo.setLevel(vo.getLevel());
			// userInfo.setLiveLevel(vo.getLiveLevel());
			// userInfo.setLocation(vo.getLocation());
			// userInfo.setLoginDate(vo.getLoginDate());
			// userInfo.setLoginIp(vo.getLoginIp());
			// userInfo.setLoginName(vo.getLoginName());
			// userInfo.setMobile(vo.getMobile());
			// userInfo.setMyConsumption(vo.getMyConsumption());
			// userInfo.setMyIncome(vo.getMyIncome());
			userInfo.setName(vo.getName());
			userInfo.setNickName(vo.getNickName());
			userInfo.setOnlineState(vo.getOnlineState());
			// userInfo.setPassword(vo.getPassword());
			// userInfo.setPhone(vo.getPhone());
			userInfo.setPhoto(vo.getPhoto());
			userInfo.setSex(vo.getSex());
			// userInfo.setSignature(vo.getSignature());
			userInfo.setUserType(vo.getUserType());
			// vo.setSig(user.getSig());
		}
		return userInfo;
	}

	public static GoldContribution GoldContributionConvert2Vo(LiveGoldContribution live, String roomId) {
		GoldContribution vo = new GoldContribution();
		if (live.getUserId() != null) {
			vo.setOwnerId(live.getUserId());
		}
		vo.setCreateDate(live.getCreateDate());
		vo.setCount(live.getCount());
		vo.setSenderId(live.getCreateById());
		vo.setRoomId(roomId);
		vo.setSenderName(live.getSenderName());
		return vo;
	}

	public static Room roomConvert2Vo(LiveRoom liveRoom) {
		Room vo = new Room();
		if (liveRoom != null) {
			vo.setId(liveRoom.getId());
			vo.setChatId(liveRoom.getChatId());
			vo.setDescription(liveRoom.getDescription());
			vo.setId(liveRoom.getId());
			vo.setPictureUrl(liveRoom.getPictureUrl());
			vo.setTitle(liveRoom.getTitle());
			vo.setOnlineNumber(liveRoom.getOnlineNumber());
			vo.setUserId(liveRoom.getUserId());
			if (liveRoom.getType() != null) {
				vo.setType(liveRoom.getType());
			}
			vo.setUserId(liveRoom.getUserId());
			vo.setLocation(liveRoom.getLocation());
			vo.setAvatar(liveRoom.getAvatar());
			vo.setUserName(liveRoom.getUserName());
			if (liveRoom.getSpecialId() != null) {
				vo.setSpecialId(liveRoom.getSpecialId());
			}
			vo.setState(liveRoom.getState());
			vo.setChannelId(liveRoom.getChannelId());
			vo.setCreateDate(liveRoom.getUpdateDate() == null ? liveRoom.getCreateDate() : liveRoom.getUpdateDate());
		}
		return vo;
	}

	public static LiveRoom voConvert2LiveRoom(Room vo) {
		LiveRoom room = new LiveRoom();
		if (vo != null) {
			if (vo.getId() != null) {
				room.setId(vo.getId());
			}
			room.setChatId(vo.getChatId());
			room.setDescription(vo.getDescription());
			room.setId(vo.getId());
			room.setPictureUrl(vo.getPictureUrl());
			room.setTitle(vo.getTitle());
			room.setCreateDate(new Date());
			room.setUpdateDate(new Date());
			room.setUserId(vo.getUserId());
			room.setUpdateById(vo.getUserId());
			room.setType(vo.getType());
			room.setLocation(vo.getLocation());
			if (vo.getOnlineNumber() != null) {
				room.setOnlineNumber(vo.getOnlineNumber());
			} else {
				room.setOnlineNumber(0l);
			}
			room.setLocation(vo.getLocation());
			room.setSpecialId(vo.getSpecialId());
			if (StringUtils.isNotBlank(vo.getSpecialId())) {
				room.setType(1);
			} else {
				room.setType(2);
			}
			room.setChannelId(vo.getChannelId());
		}
		return room;
	}

	public static LiveRecording recordingConverToEntity(Recording vo) {
		LiveRecording record = new LiveRecording();
		record.setCreateDate(new Date());
		record.setRoomId(vo.getRoomId());
		record.setType(vo.getType());
		record.setUserId(vo.getUserId());
		record.setSpecialId(vo.getSpecialId());
		record.setvId(vo.getvId());
		record.setFileSet(vo.getFileSet());
		record.setTitle(vo.getTitle());
		return record;
	}

	public static LiveRecording recordingConverToEntity(LiveRecording record, Recording vo) {
		record.setRoomId(vo.getRoomId());
		record.setType(vo.getType());
		record.setUserId(vo.getUserId());
		record.setSpecialId(vo.getSpecialId());
		record.setvId(vo.getvId());
		record.setFileSet(vo.getFileSet());
		record.setTitle(vo.getTitle());
		record.setRoom(vo.getRoom());
		return record;
	}

	public static Recording recordingConverToVo(LiveRecording entity) {
		Recording vo = new Recording();
		vo.setRoomId(entity.getRoomId());
		vo.setType(entity.getType());
		vo.setUserId(entity.getUserId());
		vo.setViewCount(entity.getViewCount());
		vo.setSpecialId(entity.getSpecialId());
		if (entity.getCreateDate() != null) {
			vo.setCreateTime(entity.getCreateDate());
		}
		vo.setvId(entity.getvId());
		vo.setFileSet(entity.getFileSet());
		vo.setTitle(entity.getTitle());
		vo.setRoom(entity.getRoom());
		return vo;
	}

	public static void recordingConverToVo(Recording vo, LiveRecording entity) {
		vo.setRoomId(entity.getRoomId());
		vo.setType(entity.getType());
		vo.setUserId(entity.getUserId());
		vo.setViewCount(entity.getViewCount());
		vo.setSpecialId(entity.getSpecialId());
		if (entity.getCreateDate() != null) {
			vo.setCreateTime(entity.getCreateDate());
		}
		vo.setvId(entity.getvId());
		vo.setFileSet(entity.getFileSet());
		vo.setTitle(entity.getTitle());
		vo.setRoom(entity.getRoom());
	}

}
